<template>
  <div class="cart_main">
    <div class="card_header">
      <div class="card_name">
        <div class="name">小尼力街头嘻哈潮流店</div>
        <div class="arrow"></div>
      </div>
      <div class="quan">领券</div>
    </div>
    <div class="card_main">
      <div class="card_select">
        <div
          :class="['card_yuan', { select: data.selected }]"
          @click="selectItem"
        ></div>
      </div>
      <div class="card_left">
        <div class="card_img">
          <img
            src="https://hhk-serverless-project-static-files.oss-cn-hangzhou.aliyuncs.com/images/assets/recommand/nanmutangshao.webp"
            alt=""
          />
        </div>
        <div class="card_info">
          <div class="info_name">oversize日系圆领</div>
          <div class="info_size">白色: L</div>
          <div class="info_status">库存紧张</div>
          <div class="info_prize">
            <div class="card_mon">￥{{ data.prize }}</div>
            <div class="card_num">
              <div class="jian" @click="decrement">-</div>
              <div class="num">{{ data.number }}</div>
              <div class="jia" @click="increment">+</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    data: Object,
  },
  setup({ data }, { emit }) {
    const decrement = () => {
      emit("decrement", data.id);
    };
    const increment = () => {
      emit("increment", data.id);
    };
    const selectItem = () => {
      emit("selectItem", data.id);
    };

    return {
      decrement,
      increment,
      selectItem,
    };
  },
};
</script>

<style scoped>
.cart_main {
  background: #fff;
  padding: 10px;
  border-radius: 10px;
  margin-top: 10px;
}
.card_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.name {
  display: inline-block;
  font-weight: 700;
  font-size: 30px;
}
.arrow {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 5px solid #ccc;
  border-top: transparent;
  border-left: transparent;
  will-change: transform;
  transform: rotate(-46deg);
}
.quan {
  color: #aaa;
  font-size: 30px;
}
.card_main {
  display: flex;
  margin-top: 20px;
}
.card_select {
  width: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.card_yuan {
  width: 50px;
  height: 50px;
  border: 5px #aaa solid;
  border-radius: 50%;
}
.card_left {
  display: flex;
  flex: 1;
}
.info_prize {
  display: flex;
}

.card_img {
  display: block;
  border-radius: 30px;
  overflow: hidden;
  margin-right: 20px;
  width: 300px;
  height: 300px;
}
.card_info {
  flex: 1;
}
.card_num {
  display: flex;
}
.info_name {
  font-weight: 700;
  font-size: 30px;
}
.info_size {
  display: inline-block;
  background: #eee;
  margin-top: 20px;
  border-radius: 10px;
  padding: 10px;
  color: #aaa;
  font-size: 30px;
}
.info_status {
  font-size: 14px;
  width: 100px;
  padding: 5px;
  color: red;
  border-radius: 10px;
  margin-top: 20px;
  border: 2px solid #ff5000;
}

.info_prize {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 60px;
  font-size: 30px;
}
.card_mon {
  color: #ff5000;
}
.card_num {
  border: #aaa solid 1px;
  border-radius: 10px;
}
.jian {
  width: 50px;
  text-align: center;
  font-size: 40px;
  border-right: 1px solid #aaa;
}
.num {
  width: 50px;
  text-align: center;
  font-size: 40px;
  border-right: 1px solid #aaa;
}
.jia {
  width: 50px;
  text-align: center;
  font-size: 40px;
}
.select {
  border-color: #ff5000;
  background: #ff5000;
}
</style>